import numpy as np
import cv2 as cv

file = "../../res/111.jpg"
org_img = cv.imread(file)
cv.imshow("resize", org_img)
img = org_img.copy()

help_str = """
1: 按比例缩放
2: 指定大小缩放
3: 修改差值方法
"""
KEY_ESC = 27
model = cv.INTER_LINEAR

while True:
    cv.imshow("resize", img)
    img = org_img.copy()
    key = cv.waitKey(100) & 0xFF
    if key == KEY_ESC:
        break
    elif key == ord("1"):
        scale = float(input("请输入缩放比例："))
        # img = cv.resize(img, None, fx=0.5, fy=0.5, interpolation=cv.INTER_LINEAR)
        img = cv.resize(img, None, fx=scale, fy=scale, interpolation=model)
    elif key == ord("2"):
        new_width = int(input("请输入缩放 宽度:"))
        new_height = int(input("请输入缩放 高度:"))
        img = cv.resize(img, (new_width, new_height), interpolation=model)
    elif key == ord("3"):
        model_str = """
参数：插值方法
0: cv.INTER_NEAREST 最近邻插值
1: cv.INTER_LINEAR 双线性插值
2: cv.INTER_CUBIC 4x4像素插值
3: cv.INTER_AREA 基于局部像素的重采样
"""
        model = int(input("请输入差值方法："))

cv.destroyAllWindows()
